home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
BBS-Archive
/
Comm
/
term-source.lha
/
Extras
/
Source
/
gtlayout-Source.lha
/
LT_HandleInput.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-11
|
42KB
|
1,869 lines
/* GadTools layout toolkit
**
** Copyright © 1993-1995 by Olaf `Olsen' Barthel
** Freely distributable.
*/
#include "gtlayout_global.h"
VOID LIBENT
LT_HandleInput(REG(a0) LayoutHandle *Handle,REG(d0) ULONG MsgQualifier,REG(a1) ULONG *MsgClass,REG(a2) UWORD *MsgCode,REG(a3) struct Gadget **MsgGadget)
{
ObjectNode *Node;
BOOLEAN Activate = FALSE;
if(!Handle)
return;
if(Handle -> Failed)
{
*MsgClass = IDCMP_CLOSEWINDOW;
if(!Handle -> NeedDelay)
Handle -> NeedDelay = TRUE;
else
LTP_Delay(0,500000);
return;
}
switch(*MsgClass)
{
case IDCMP_CHANGEWINDOW:
if(!(Handle -> Window -> Flags & WFLG_SIZEGADGET) && (Handle -> Window -> Flags & WFLG_HASZOOM) && !V39)
{
#ifdef DO_BOOPSI_KIND
if(Handle -> BOOPSIList)
RefreshGList((struct Gadget *)Handle -> BOOPSIList,Handle -> Window,NULL,(UWORD)-1);
#endif /* DO_BOOPSI_KIND */
RefreshGList(Handle -> List,Handle -> Window,NULL,(UWORD)-1);
GT_RefreshWindow(Handle -> Window,NULL);
LTP_DrawGroup(Handle,Handle -> TopGroup);
}
break;
case IDCMP_NEWSIZE:
// Did the user cancel the resize operation?
if(Handle -> SizeVerified && Handle -> SizeWidth == Handle -> Window -> Width && Handle -> SizeHeight == Handle -> Window -> Height)
{
Handle -> SizeVerified = FALSE;
Handle -> SizeWidth = 0;
Handle -> SizeHeight = 0;
// Put the gadgets back in
AddGList(Handle -> Window,Handle -> List,(UWORD)-1,(UWORD)-1,NULL);
}
else
{
struct IBox Box;
Handle -> SizeWidth = 0;
Handle -> SizeHeight = 0;
Box . Left = 0;
Box . Top = 0;
Box . Width = Handle -> Window -> Width;
Box . Height = Handle -> Window -> Height;
LT_LockWindow(Handle -> Window);
if(Handle -> ResizeView)
Handle -> ResizeView -> Special . List . IgnoreListContents = TRUE;
LT_RebuildTags(Handle,TRUE,
LAWN_Bounds, &Box,
TAG_DONE);
LT_UnlockWindow(Handle -> Window);
if(Handle -> Failed)
*MsgClass = IDCMP_CLOSEWINDOW;
else
*MsgClass = NULL;
}
break;
case IDCMP_REFRESHWINDOW:
if(Handle -> AutoRefresh)
{
LT_BeginRefresh(Handle);
LT_EndRefresh(Handle,TRUE);
*MsgClass = NULL;
}
break;
case IDCMP_INTUITICKS:
if(Handle -> ActiveIncrementer)
{
Handle -> IncrementerCountdown--;
if(Handle -> IncrementerCountdown <= 0)
{
if(Handle -> ActiveIncrementer -> Host -> Flags & GFLG_SELECTED)
{
if(Handle -> ActiveIncrementer -> Type == TAPEDECK_KIND)
{
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 0;
*MsgGadget = Handle -> ActiveIncrementer -> Host;
}
else
{
struct ObjectNode *Parent;
LONG Number;
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 0;
*MsgGadget = Handle -> ActiveIncrementer -> Special . Incrementer . Parent;
Parent = (*MsgGadget) -> UserData;
if(Parent -> Special . Integer . IncrementerHook)
Number = CallHookPkt(Parent -> Special . Integer . IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE),Handle -> ActiveIncrementer -> Special . Incrementer . Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
else
Number = ((LONG)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE)) + Handle -> ActiveIncrementer -> Special . Incrementer . Amount;
if(Number >= Parent -> Min && Number <= Parent -> Max)
LT_SetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,GTIN_Number,Number,TAG_DONE);
}
}
Handle -> IncrementerCountdown = 2;
}
}
break;
case IDCMP_RAWKEY:
{
UBYTE Buffer[10],Key;
struct InputEvent event;
BOOLEAN KeyUp;
if((*MsgCode & ~IECODE_UP_PREFIX) == 95 && Handle -> HelpHook)
{
if(!(*MsgCode & IECODE_UP_PREFIX))
{
ObjectNode *Item;
struct HelpMsg Message;
struct IBox Box;
Item = LTP_FindNode_Position(Handle -> TopGroup,Handle -> Window -> MouseX,Handle -> Window -> MouseY);
if(Item == Handle -> TopGroup)
{
if(Item -> ID <= PHANTOM_GROUP_ID)
Item = NULL;
}
if(Item)
{
Message . ObjectID = Item -> ID;
Box . Left = Item -> Left;
Box . Top = Item -> Top;
Box . Width = Item -> Width;
Box . Height = Item -> Height;
}
else
{
Message . ObjectID = -1;
Box . Left = 0;
Box . Top = 0;
Box . Width = Handle -> Window -> Width;
Box . Height = Handle -> Window -> Height;
}
Message . Handle = Handle;
CallHookPkt(Handle -> HelpHook,&Message,&Box);
}
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
break;
}
if((*MsgCode >= 99 && *MsgCode <= 103) || *MsgCode == 96 || *MsgCode == 97)
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
break;
}
event . ie_NextEvent = NULL;
event . ie_Code = (*MsgCode) & ~IECODE_UP_PREFIX;
event . ie_Qualifier = MsgQualifier & ~QUALIFIER_SHIFT;
event . ie_Class = IECLASS_RAWKEY;
event . ie_SubClass = 0;
event . ie_position . ie_addr = (APTR)*MsgGadget;
Buffer[0] = 0;
if(MapRawKey(&event,Buffer,9,NULL) < 1)
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
break;
}
if(!(Key = Buffer[0]))
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
break;
}
if((*MsgCode) & IECODE_UP_PREFIX)
KeyUp = TRUE;
else
KeyUp = FALSE;
if(!KeyUp && Handle -> CursorKey && (*MsgCode == CURSORUP || *MsgCode == CURSORDOWN))
{
ObjectNode *Node;
struct Gadget *Gadget;
LONG NewState;
Handle -> ClickSeconds = Handle -> ClickMicros = 0;
Node = Handle -> CursorKey;
Gadget = Node -> Host;
NewState = Node -> Current;
if(*MsgCode == CURSORDOWN)
{
if(MsgQualifier & QUALIFIER_SHIFT)
NewState += Node -> Lines;
else
{
if(MsgQualifier & (QUALIFIER_ALT | QUALIFIER_CONTROL))
NewState = Node -> Max;
else
NewState++;
}
}
else
{
if(MsgQualifier & QUALIFIER_SHIFT)
NewState -= Node -> Lines;
else
{
if(MsgQualifier & (QUALIFIER_ALT | QUALIFIER_CONTROL))
NewState = Node -> Min;
else
NewState--;
}
}
if(NewState < Node -> Min)
NewState = Node -> Min;
else
{
if(NewState > Node -> Max)
NewState = Node -> Max;
}
if(NewState != Node -> Current && Node -> Max != Node -> Min)
{
Node -> Current = NewState;
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTLV_Top, Node -> Current,
GTLV_MakeVisible, Node -> Current,
Node -> Special . List . LinkID != -1 ? GTLV_Selected : TAG_IGNORE,Node -> Current,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_GADGETUP;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
return;
}
if(Key == '\t' && !KeyUp)
{
ObjectNode *Node;
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
if(Node = Handle -> TabKey)
{
if(!(Node -> Disabled))
{
LONG Choice;
if(MsgQualifier & QUALIFIER_SHIFT)
Choice = Node -> Current - 1;
else
Choice = Node -> Current + 1;
if(Choice < Node -> Min)
Choice = Node -> Max;
else
{
if(Choice > Node -> Max)
Choice = Node -> Min;
}
if(Choice != Node -> Current)
{
LONG AutoPageID,Type;
if(Node -> Type == CYCLE_KIND)
{
AutoPageID = Node -> Special . Cycle . AutoPageID;
Type = GTCY_Active;
*MsgClass = IDCMP_GADGETUP;
LTP_BlinkButton(Handle,Node -> Host);
}
else
{
AutoPageID = Node -> Special . Radio . AutoPageID;
Type = GTMX_Active;
*MsgClass = IDCMP_GADGETDOWN;
}
*MsgCode = (UWORD)Choice;
*MsgGadget = Node -> Host;
LT_SetAttributes(Handle,Node -> ID,
Type,Choice,
TAG_DONE);
if(AutoPageID != -1)
{
LT_SetAttributes(Handle,AutoPageID,
LAGR_ActivePage,Choice,
TAG_DONE);
if(Handle -> Failed)
*MsgClass = IDCMP_CLOSEWINDOW;
}
}
}
}
return;
}
if(Key == '\33' && !KeyUp)
{
ObjectNode *Node;
Handle -> ClickSeconds = Handle -> ClickMicros = 0;
if(Node = Handle -> EscKey)
{
if(!Node -> Disabled)
{
LTP_BlinkButton(Handle,Node -> Host);
*MsgCode = 0;
*MsgGadget = Node -> Host;
*MsgClass = IDCMP_GADGETUP;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
return;
}
if(Handle -> Window -> Flags & WFLG_CLOSEGADGET)
{
*MsgCode = 0;
*MsgGadget = NULL;
*MsgClass = IDCMP_CLOSEWINDOW;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
return;
}
else
{
struct Gadget *Gadget;
ObjectNode *Node;
LONG i;
BOOLEAN FoundIt = FALSE,
Forward;
if(MsgQualifier & QUALIFIER_SHIFT)
Forward = FALSE;
else
Forward = TRUE;
if(Handle -> ReturnKey && Key == '\r')
{
Node = Handle -> ReturnKey;
if(!KeyUp && !Node -> Disabled)
{
LTP_BlinkButton(Handle,Node -> Host);
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 0;
*MsgGadget = Node -> Host;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
Handle -> ClickSeconds = Handle -> ClickMicros = 0;
return;
}
for(i = 0 ; !FoundIt && i < Handle -> Count ; i++)
{
if(Gadget = Handle -> GadgetArray[i])
{
if(GETOBJECT(Gadget,Node))
{
if(Key == Node -> Key)
{
if(Node -> Disabled)
break;
else
{
switch(Node -> Type)
{
#ifdef DO_BOOPSI_KIND
case BOOPSI_KIND:
if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
{
if(Node -> Special . BOOPSI . ActivateHook)
{
if(CallHookPkt(Node -> Special . BOOPSI . ActivateHook,(APTR)Handle,(APTR)Node -> Host))
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
break;
}
}
*MsgClass = IDCMP_GADGETUP;
*MsgCode = (MsgQualifier & QUALIFIER_SHIFT) ? -1 : 1;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
break;
#endif /* DO_BOOPSI_KIND */
#ifdef DO_TAPEDECK_KIND
case TAPEDECK_KIND:
if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
{
if(Node -> Special . TapeDeck . Toggle)
{
LT_SetAttributes(Handle,Node -> ID,
LAPR_Object, Node,
LATD_Pressed, !Node -> Current,
TAG_DONE);
LTP_PutStorage(Node);
}
else
LTP_BlinkButton(Handle,Gadget);
if(Gadget -> Flags & GFLG_SELECTED)
*MsgCode = TRUE;
else
*MsgCode = FALSE;
*MsgClass = IDCMP_GADGETUP;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
break;
#endif /* DO_TAPEDECK_KIND */
case CHECKBOX_KIND:
if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
{
Node -> Current = !Node -> Current;
LTP_PutStorage(Node);
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTCB_Checked,Node -> Current,
TAG_DONE);
*MsgClass = IDCMP_GADGETUP;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
FoundIt = TRUE;
break;
case LISTVIEW_KIND:
if(!KeyUp)
{
BOOLEAN setAttrs = FALSE;
if(Forward)
{
if(Node -> Current < Node -> Max)
{
Node -> Current++;
setAttrs = TRUE;
}
}
else
{
if(Node -> Current > Node -> Min)
{
Node -> Current--;
setAttrs = TRUE;
}
}
if(setAttrs)
{
if(Node -> Current < 0)
{
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTLV_Selected,Node -> Current,
TAG_DONE);
}
else
{
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTLV_Top, Node -> Current,
GTLV_MakeVisible, Node -> Current,
Node -> Special . List . LinkID != -1 ? GTLV_Selected : TAG_IGNORE,Node -> Current,
TAG_DONE);
}
LTP_PutStorage(Node);
*MsgClass = IDCMP_GADGETUP;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
FoundIt = TRUE;
break;
case MX_KIND:
if(!KeyUp)
{
if(Forward)
{
if(Node -> Current < Node -> Max)
{
Node -> Current++;
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTMX_Active,Node -> Current,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_GADGETDOWN;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
else
{
if(Node -> Current > Node -> Min)
{
Node -> Current--;
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTMX_Active,Node -> Current,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_GADGETDOWN;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
*MsgClass = NULL;
}
}
else
*MsgClass = NULL;
if(*MsgClass)
{
if(Node -> Special . Radio . AutoPageID != -1)
{
LT_SetAttributes(Handle,Node -> Special . Radio . AutoPageID,
LAGR_ActivePage,Node -> Current,
TAG_DONE);
if(Handle -> Failed)
*MsgClass = IDCMP_CLOSEWINDOW;
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
}
FoundIt = TRUE;
break;
case TEXT_KIND:
if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
{
if(Node -> Special . Text . Picker)
{
LTP_BlinkButton(Handle,Node -> Special . Text . Picker);
*MsgClass = IDCMP_IDCMPUPDATE;
*MsgCode = 0;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
FoundIt = TRUE;
break;
case NUMBER_KIND:
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
FoundIt = TRUE;
break;
case CYCLE_KIND:
if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
{
LTP_BlinkButton(Handle,Gadget);
if(Forward)
{
if(Node -> Current < Node -> Max)
Node -> Current++;
else
Node -> Current = Node -> Min;
}
else
{
if(Node -> Current > Node -> Min)
Node -> Current--;
else
Node -> Current = Node -> Max;
}
LTP_PutStorage(Node);
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTCY_Active,Node -> Current,
TAG_DONE);
*MsgClass = IDCMP_GADGETUP;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
if(Node -> Special . Cycle . AutoPageID != -1)
{
LT_SetAttributes(Handle,Node -> Special . Cycle . AutoPageID,
LAGR_ActivePage,Node -> Current,
TAG_DONE);
if(Handle -> Failed)
*MsgClass = IDCMP_CLOSEWINDOW;
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
FoundIt = TRUE;
break;
case PALETTE_KIND:
if(!KeyUp)
{
if(Node -> Special . Palette . UsePicker)
{
if(!(MsgQualifier & IEQUALIFIER_REPEAT))
{
LTP_BlinkButton(Handle,Node -> Special . Palette . Picker);
*MsgClass = IDCMP_IDCMPUPDATE;
*MsgCode = 0;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
FoundIt = TRUE;
break;
}
if(Node -> Special . Palette . TranslateBack)
{
LONG Index = Node -> Special . Palette . TranslateBack[Node -> Current];
if(Index < Node -> Min)
Index = Node -> Min;
else
{
if(Index > Node -> Max)
Index = Node -> Max;
}
if(Forward)
{
if(Index < Node -> Max)
Index++;
else
Index = Node -> Min;
}
else
{
if(Index > Node -> Min)
Index--;
else
Index = Node -> Max;
}
if(Index < Node -> Min)
Index = Node -> Min;
else
{
if(Index > Node -> Max)
Index = Node -> Max;
}
Node -> Current = Node -> Special . Palette . ColourTable[Index];
}
else
{
if(Forward)
{
if(Node -> Current < Node -> Max)
Node -> Current++;
else
Node -> Current = Node -> Min;
}
else
{
if(Node -> Current > Node -> Min)
Node -> Current--;
else
Node -> Current = Node -> Max;
}
}
LTP_PutStorage(Node);
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTPA_Color,Node -> Current,
TAG_DONE);
*MsgClass = IDCMP_GADGETUP;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
FoundIt = TRUE;
break;
case SLIDER_KIND:
if(KeyUp)
{
*MsgClass = IDCMP_GADGETUP;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Forward)
{
if(Node -> Current < Node -> Max)
{
Node -> Current++;
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTSL_Level,Node -> Current,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_MOUSEMOVE;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
else
{
if(Node -> Current > Node -> Min)
{
Node -> Current--;
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTSL_Level,Node -> Current,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_MOUSEMOVE;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
}
FoundIt = TRUE;
break;
#ifdef DO_LEVEL_KIND
case LEVEL_KIND:
if(KeyUp)
{
*MsgClass = IDCMP_GADGETUP;
*MsgCode = Node -> Special . Level . Level;
*MsgGadget = Gadget;
LTP_PutStorage(Node);
}
else
{
if(Forward)
{
if(Node -> Special . Level . Level < Node -> Special . Level . Max)
{
Node -> Special . Level . Level++;
LT_SetAttributes(Handle,Node -> ID,
LAPR_Object, Node,
LAVL_Level, Node -> Special . Level . Level,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_MOUSEMOVE;
*MsgCode = Node -> Special . Level . Level;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
else
{
if(Node -> Special . Level . Level > Node -> Special . Level . Min)
{
Node -> Special . Level . Level--;
LT_SetAttributes(Handle,Node -> ID,
LAPR_Object, Node,
LAVL_Level, Node -> Special . Level . Level,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_MOUSEMOVE;
*MsgCode = Node -> Special . Level . Level;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
}
FoundIt = TRUE;
break;
#endif /* DO_LEVEL_KIND */
case SCROLLER_KIND:
if(KeyUp)
{
*MsgClass = IDCMP_GADGETUP;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Forward)
{
if(Node -> Current < Node -> Max)
{
Node -> Current++;
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTSC_Top,Node -> Current,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_MOUSEMOVE;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
else
{
if(Node -> Current > Node -> Min)
{
Node -> Current--;
GT_SetGadgetAttrs(Gadget,Handle -> Window,NULL,
GTSC_Top,Node -> Current,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_MOUSEMOVE;
*MsgCode = Node -> Current;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
}
}
FoundIt = TRUE;
break;
case STRING_KIND:
case FRACTION_KIND:
case PASSWORD_KIND:
if(!KeyUp)
{
if(Node -> Special . String . Picker && !Forward)
{
LTP_BlinkButton(Handle,Node -> Special . String . Picker);
*MsgClass = IDCMP_IDCMPUPDATE;
*MsgCode = 0;
*MsgGadget = Gadget;
}
else
{
ActivateGadget(Gadget,Handle -> Window,NULL);
*MsgClass = IDCMP_GADGETDOWN;
*MsgCode = 0;
*MsgGadget = Gadget;
Handle -> Previous = Gadget;
}
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
FoundIt = TRUE;
break;
case INTEGER_KIND :
if(!KeyUp)
{
if(Node -> Special . Integer . UseIncrementers)
{
ObjectNode *incNode,*Parent = (ObjectNode *)Gadget -> UserData;
LONG Number;
struct Gadget *Incrementer;
if(Forward)
{
incNode = Node -> Special . Integer . RightIncrementer -> UserData;
Incrementer = Node -> Special . Integer . RightIncrementer;
}
else
{
incNode = Node -> Special . Integer . LeftIncrementer -> UserData;
Incrementer = Node -> Special . Integer . LeftIncrementer;
}
if(Parent -> Special . Integer . IncrementerHook)
Number = CallHookPkt(Parent -> Special . Integer . IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE),incNode -> Special . Incrementer . Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
else
Number = LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE) + incNode -> Special . Incrementer . Amount;
if(Number >= Parent -> Min && Number <= Parent -> Max)
{
LTP_BlinkButton(Handle,Incrementer);
LT_SetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,GTIN_Number,Number,TAG_DONE);
*MsgClass = IDCMP_GADGETUP;
LTP_PutStorage(Node);
}
}
else
{
ActivateGadget(Gadget,Handle -> Window,NULL);
*MsgClass = IDCMP_GADGETDOWN;
}
*MsgCode = 0;
*MsgGadget = Gadget;
Handle -> Previous = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
FoundIt = TRUE;
break;
case BUTTON_KIND:
if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
{
LTP_BlinkButton(Handle,Gadget);
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 0;
*MsgGadget = Gadget;
}
else
{
if(Handle -> RawKeyFilter)
*MsgClass = NULL;
}
FoundIt = TRUE;
break;
}
}
}
}
}
}
if(FoundIt)
Handle -> ClickSeconds = Handle -> ClickMicros = 0;
}
break;
}
case IDCMP_GADGETDOWN:
if(GETOBJECT((*MsgGadget),Node))
{
if(Node -> Type != LISTVIEW_KIND)
Handle -> ClickSeconds = Handle -> ClickMicros = 0;
switch(Node -> Type)
{
#ifdef DO_LEVEL_KIND
case LEVEL_KIND:
Handle -> CurrentLevel = Node;
*MsgCode = Node -> Special . Level . Level;
break;
#endif /* DO_LEVEL_KIND */
case STRING_KIND:
case INTEGER_KIND:
case FRACTION_KIND:
case PASSWORD_KIND:
Handle -> Previous = *MsgGadget;
break;
#ifdef DO_TAPEDECK_KIND
case TAPEDECK_KIND:
if(Node -> Special . TapeDeck . Tick)
{
Handle -> ActiveIncrementer = Node;
Handle -> IncrementerCountdown = 2;
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 0;
}
else
{
if(Node -> Special . TapeDeck . Toggle)
{
if((*MsgGadget) -> Flags & GFLG_SELECTED)
*MsgCode = TRUE;
else
*MsgCode = FALSE;
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
*MsgClass = IDCMP_GADGETUP;
}
}
break;
#endif /* DO_TAPEDECK_KIND */
case MX_KIND:
if(!V39 && Node -> Disabled)
{
GT_SetGadgetAttrs(*MsgGadget,Handle -> Window,NULL,
GTMX_Active,Node -> Current,
TAG_DONE);
*MsgClass = NULL;
}
else
{
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Node -> Special . Radio . AutoPageID != -1)
{
LT_SetAttributes(Handle,Node -> Special . Radio . AutoPageID,
LAGR_ActivePage,Node -> Current,
TAG_DONE);
if(Handle -> Failed)
*MsgClass = IDCMP_CLOSEWINDOW;
else
*MsgClass = NULL;
}
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
}
break;
case SLIDER_KIND:
if(Node -> Min < 0)
Node -> Current = (WORD)*MsgCode;
else
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
break;
case SCROLLER_KIND:
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
break;
case INCREMENTER_KIND:
Handle -> ActiveIncrementer = Node;
Handle -> IncrementerCountdown = 6;
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 0;
*MsgGadget = Node -> Special . Incrementer . Parent;
/* ALWAYS */
{
struct ObjectNode *Parent = (ObjectNode *)(*MsgGadget) -> UserData;
LONG Number;
if(Parent -> Special . Integer . IncrementerHook)
Number = CallHookPkt(Parent -> Special . Integer . IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE),Node -> Special . Incrementer . Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
else
Number = LT_GetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,TAG_DONE) + Node -> Special . Incrementer . Amount;
if(Number >= Parent -> Min && Number <= Parent -> Max)
LT_SetAttributes(Handle,Parent -> ID,LAPR_Object,Parent,GTIN_Number,Number,TAG_DONE);
else
*MsgClass = NULL;
}
break;
}
}
break;
case IDCMP_MOUSEBUTTONS:
if(((*MsgCode) & IECODE_UP_PREFIX) && Handle -> Previous)
Activate = TRUE;
if(*MsgCode == SELECTDOWN)
{
ObjectNode *Node;
WORD x,y;
x = Handle -> Window -> MouseX;
y = Handle -> Window -> MouseY;
Node = LTP_FindNode_Position(Handle -> TopGroup,x,y);
if(Node && !Node -> Disabled)
{
WORD Index;
switch(Node -> Type)
{
case CHECKBOX_KIND:
Node -> Current = !Node -> Current;
LTP_PutStorage(Node);
GT_SetGadgetAttrs(Node -> Host,Handle -> Window,NULL,
GTCB_Checked,Node -> Current,
TAG_DONE);
*MsgClass = IDCMP_GADGETUP;
*MsgCode = Node -> Current;
*MsgGadget = Node -> Host;
break;
case MX_KIND:
Index = LTP_Find_Clicked_Item(Handle,Node,x,y);
if(Index != -1)
{
GT_SetGadgetAttrs(Node -> Host,Handle -> Window,NULL,
GTMX_Active,Index,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_GADGETDOWN;
*MsgCode = Index;
*MsgGadget = Node -> Host;
}
break;
}
}
}
else
{
// Now this is a real kludge; as of v37 the
// MX_KIND labels are not part of the gadget
// itself and a plain SELECTDOWN mouse event
// is sent as soon as the user clicks on it.
// This changed with v39 which presumably had
// some code in there to map mouse clicks on
// the gadget labels to proper buttonpress
// events. Now, try as you might the click is
// swallowed and we have to do with the
// SELECTUP, sigh...
if(V39 && *MsgCode == SELECTUP)
{
ObjectNode *Node;
WORD x,y;
x = Handle -> Window -> MouseX;
y = Handle -> Window -> MouseY;
Node = LTP_FindNode_Position(Handle -> TopGroup,x,y);
if(Node && Node -> Type == MX_KIND && !Node -> Disabled)
{
WORD Index;
Index = LTP_Find_Clicked_Item(Handle,Node,x,y);
if(Index != -1)
{
GT_SetGadgetAttrs(Node -> Host,Handle -> Window,NULL,
GTMX_Active,Index,
TAG_DONE);
LTP_PutStorage(Node);
*MsgClass = IDCMP_GADGETDOWN;
*MsgCode = Index;
*MsgGadget = Node -> Host;
}
}
}
}
if((*MsgCode == SELECTUP) && (Handle -> ActiveIncrementer))
{
if(Handle -> ActiveIncrementer -> Type == TAPEDECK_KIND && Handle -> ActiveIncrementer -> Special . TapeDeck . Tick)
{
Handle -> ActiveIncrementer = NULL;
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 1;
}
else
{
Handle -> ActiveIncrementer = NULL;
if(((ObjectNode *)Handle -> ActiveIncrementer -> Special . Incrementer . Parent -> UserData) -> Type == INTEGER_KIND)
{
*MsgGadget = Handle -> ActiveIncrementer -> Special . Incrementer . Parent;
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 1;
}
}
}
break;
case IDCMP_GADGETUP:
#ifdef DO_LEVEL_KIND
Handle -> CurrentLevel = NULL;
#endif /* DO_LEVEL_KIND */
if(GETOBJECT((*MsgGadget),Node))
{
if(Node -> Type != LISTVIEW_KIND)
Handle -> ClickSeconds = Handle -> ClickMicros = 0;
switch(Node -> Type)
{
case FRACTION_KIND:
LT_SetAttributes(Handle,(*MsgGadget) -> GadgetID,LAFC_Number,LT_GetAttributes(Handle,(*MsgGadget) -> GadgetID,TAG_DONE),TAG_DONE);
/* FALLS THROUGH */
case PASSWORD_KIND:
case STRING_KIND:
LTP_PutStorage(Node);
if(*MsgCode == 0x5F && Handle -> HelpHook)
{
struct HelpMsg Message;
struct IBox Box;
Message . ObjectID = Node -> ID;
Box . Left = Node -> Left;
Box . Top = Node -> Top;
Box . Width = Node -> Width;
Box . Height = Node -> Height;
Message . Handle = Handle;
CallHookPkt(Handle -> HelpHook,&Message,&Box);
*MsgClass = NULL;
}
else
Handle -> Previous = NULL;
break;
case INTEGER_KIND:
{
struct StringInfo *StringInfo = (struct StringInfo *)(*MsgGadget) -> SpecialInfo;
LONG Contents = StringInfo -> LongInt;
if(Contents < Node -> Min)
Contents = Node -> Min;
else
{
if(Contents > Node -> Max)
Contents = Node -> Max;
}
LT_SetAttributes(Handle,(*MsgGadget) -> GadgetID,GTIN_Number,Contents,TAG_DONE);
LTP_PutStorage(Node);
if(*MsgCode == 0x5F && Handle -> HelpHook)
{
struct HelpMsg Message;
struct IBox Box;
Message . ObjectID = Node -> ID;
Box . Left = Node -> Left;
Box . Top = Node -> Top;
Box . Width = Node -> Width;
Box . Height = Node -> Height;
Message . Handle = Handle;
CallHookPkt(Handle -> HelpHook,&Message,&Box);
*MsgClass = NULL;
}
else
Handle -> Previous = NULL;
break;
}
case CHECKBOX_KIND:
if(!V39)
{
if((*MsgGadget) -> Flags & GFLG_SELECTED)
*MsgCode = TRUE;
else
*MsgCode = FALSE;
}
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
break;
#ifdef DO_TAPEDECK_KIND
case TAPEDECK_KIND:
if(Node -> Special . TapeDeck . Tick)
{
Handle -> ActiveIncrementer = NULL;
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 1;
}
else
{
if(Node -> Special . TapeDeck . Toggle)
{
if((*MsgGadget) -> Flags & GFLG_SELECTED)
*MsgCode = TRUE;
else
*MsgCode = FALSE;
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
}
}
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
break;
#endif /* DO_TAPEDECK_KIND */
case CYCLE_KIND:
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
if(Node -> Special . Cycle . AutoPageID != -1)
{
LT_SetAttributes(Handle,Node -> Special . Cycle . AutoPageID,
LAGR_ActivePage,Node -> Current,
TAG_DONE);
if(Handle -> Failed)
*MsgClass = IDCMP_CLOSEWINDOW;
else
*MsgClass = NULL;
}
break;
case PALETTE_KIND:
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
break;
case MX_KIND:
if(!V39 && Node -> Disabled)
{
GT_SetGadgetAttrs(*MsgGadget,Handle -> Window,NULL,
GTMX_Active,Node -> Current,
TAG_DONE);
*MsgClass = NULL;
}
else
{
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Node -> Special . Radio . AutoPageID != -1)
{
LT_SetAttributes(Handle,Node -> Special . Radio . AutoPageID,
LAGR_ActivePage,Node -> Current,
TAG_DONE);
if(Handle -> Failed)
*MsgClass = IDCMP_CLOSEWINDOW;
else
*MsgClass = NULL;
}
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
}
break;
case SLIDER_KIND:
if(Node -> Min < 0)
Node -> Current = (WORD)*MsgCode;
else
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
break;
#ifdef DO_LEVEL_KIND
case LEVEL_KIND:
// *MsgClass = IDCMP_MOUSEMOVE; // Careful, may cause trouble with existing applications!
*MsgCode = Node -> Special . Level . Level;
*MsgGadget = Node -> Host;
LTP_PutStorage(Node);
break;
#endif /* DO_LEVEL_KIND */
case SCROLLER_KIND:
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
break;
case PICKER_KIND:
*MsgClass = IDCMP_IDCMPUPDATE;
*MsgCode = 0;
*MsgGadget = Node -> Special . Picker . Parent;
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
break;
case INCREMENTER_KIND:
if(((ObjectNode *)Handle -> ActiveIncrementer -> Special . Incrementer . Parent -> UserData) -> Type == INTEGER_KIND)
{
*MsgGadget = Handle -> ActiveIncrementer -> Special . Incrementer . Parent;
*MsgClass = IDCMP_GADGETUP;
*MsgCode = 1;
}
Handle -> ActiveIncrementer = NULL;
break;
case LISTVIEW_KIND:
if(Node -> Current != *MsgCode || Node != Handle -> ClickObject)
{
CurrentTime(&Handle -> ClickSeconds,&Handle -> ClickMicros);
Handle -> ClickObject = Node;
}
else
{
ULONG Seconds,Micros;
CurrentTime(&Seconds,&Micros);
if(DoubleClick(Handle -> ClickSeconds,Handle -> ClickMicros,Seconds,Micros))
*MsgClass = IDCMP_IDCMPUPDATE;
Handle -> ClickSeconds = Seconds;
Handle -> ClickMicros = Micros;
}
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
if(Node -> Special . List . Link)
{
Handle -> Previous = Node -> Special . List . Link;
if(!Node -> PageSelector)
Activate = TRUE;
}
else
{
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
}
break;
default:
if(Handle -> Previous && !Node -> PageSelector)
Activate = TRUE;
break;
}
}
break;
case IDCMP_MOUSEMOVE:
#ifdef DO_LEVEL_KIND
if(Handle -> CurrentLevel)
Node = Handle -> CurrentLevel;
else
#endif
GETOBJECT((*MsgGadget),Node);
if(Node)
{
if(Node -> Type != LISTVIEW_KIND)
Handle -> ClickSeconds = Handle -> ClickMicros = 0;
switch(Node -> Type)
{
case SLIDER_KIND:
if(Node -> Min < 0)
Node -> Current = (WORD)*MsgCode;
else
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
break;
case SCROLLER_KIND:
Node -> Current = *MsgCode;
LTP_PutStorage(Node);
break;
#ifdef DO_LEVEL_KIND
case LEVEL_KIND:
*MsgCode = Node -> Special . Level . Level;
*MsgGadget = Node -> Host;
LTP_PutStorage(Node);
break;
#endif /* DO_LEVEL_KIND */
}
}
break;
case IDCMP_ACTIVEWINDOW:
if(Handle -> Previous)
{
Activate = TRUE;
*MsgClass = IDCMP_GADGETDOWN;
*MsgCode = 0;
*MsgGadget = Handle -> Previous;
}
break;
case IDCMP_INACTIVEWINDOW:
Handle -> ActiveIncrementer = NULL;
break;
}
if(Handle -> AutoActivate && Activate && Handle -> Previous)
{
if(GETOBJECT(Handle -> Previous,Node))
{
if(!Node -> Disabled)
{
if(Node -> Type == BOOPSI_KIND && Node -> Special . BOOPSI . ActivateHook)
CallHookPkt(Node -> Special . BOOPSI . ActivateHook,(APTR)Handle,(APTR)Node -> Host);
else
ActivateGadget(Handle -> Previous,Handle -> Window,NULL);
}
}
}
}